<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="../common/taglibs.jsp" %>
<%
    response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setDateHeader("Expires", 0);
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<jsp:include page="/page/common/include.jsp"></jsp:include>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
	
	/** 初始化新增Panel位置 */
	$("#addPanel").offset({
		top:30,
		left:($(window).width()-400)*0.5
	});
	
	/** 初始化新增Panel */
	$("#addPanel").panel({
		width:400,
		height:300,
		onBeforeOpen:function(){
			/** 初始化角色信息下拉列表 */
			$('#role_input').combobox({
				valueField:'value',
				textField:'name',
				panelHeight:'auto',
				editable:false,
				multiple:true,
				url:'<%=request.getContextPath()%>/roleInfo/roleInfoAction!getRoleInfoComboxValue.do',
				formatter: function(row){
					return "<input type='checkbox' id='ch_add_"+row.value+"'/>"+row.name;
				},
				onLoadSuccess:function(){
					
				},
				onChange:function(newValue,oldValue){
					$("#userInfo_roleId").val(newValue);
				},
				onSelect:function(record){
					document.getElementById("ch_add_"+record.value).checked = true;
				},
				onUnselect:function(record){
					document.getElementById("ch_add_"+record.value).checked = false;
				}
			});
		}
	});
});

/**
 * 表单提交
 */
function formSubmit(){
	if(validateForm()){
		disableLinkButton();
		$('#form1').ajaxSubmit({
			type:"POST",
			url: '<%=request.getContextPath()%>/userInfo/userInfoAction!addUserInfo.do',
			success:function(data){
				enableLinkButton();
				var j = JSON.parse(data);
				if (j.result = 'success') {
					messageAlertInfo("操作结果",j.msg,formClear);
				} else {
					messageAlertError("操作结果",j.msg);
				}
			}
		}); 
	}
}

/**
 * 表单验证
 */
function validateForm(){
	return true;
}

/**
 * 清空表单的值
 */
function formClear(){
	goToPage('<%=request.getContextPath()%>/userInfo/userInfoAction!initAddUserInfo.do');
}

</script>
</head>

<body style="background: white;" >
	<div id="addPanel" style="position:absolute;padding-top: 10px" align="center">
		<form id="form1">
		    	<table>
		    		<s:hidden name="userInfo.roleId" />
		    		<tr>
		    			<td>登录名:</td>
		    			<td>
		    				<s:textfield name="userInfo.loginName" />
		    			</td>
		    		</tr>
		    		<tr>
		    			<td>显示名称:</td>
		    			<td>
		    				<s:textfield name="userInfo.realName" />
		    			</td>
		    		</tr>
		    		<tr>
		    			<td>密码:</td>
		    			<td>
		    				<s:textfield name="userInfo.password" />
		    			</td>
		    		</tr>
		    		<tr>
		    			<td>角色:</td>
		    			<td>
		    				<input id="role_input" style="width:154px;">
							</input>
		    			</td>
		    		</tr>
		    		<tr>
		    			<td>部门编号:</td>
		    			<td>
		    				<s:textfield name="userInfo.deptNo" />
		    			</td>
		    		</tr>
		    		<tr>
		    			<td>邮箱:</td>
		    			<td>
		    				<s:textfield name="userInfo.email" />
		    			</td>
		    		</tr>
		    		<tr>
		    			<td>联系电话:</td>
		    			<td>
		    				<s:textfield name="userInfo.tel" />
		    			</td>
		    		</tr>
		    		<tr>
		    			<td>出生日期 :</td>
		    			<td>
							<s:textfield name="userInfo.birthday" size="20" cssClass="Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'%y-%M-{%d}'})" />
		    			</td>
		    		</tr>
		    		<tr>
		    			<td colspan="2" align="center" style="padding: 15px">
		    				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="formSubmit()">提交</a>
							<a class="easyui-linkbutton" data-options="iconCls:'icon-reload'" href="javascript:void(0)" onclick="formClear()">清空</a>
		    			</td>
		    		</tr>
		    	</table>
	    	</form>
	</div>	
</body>
</html>